package cn.b.sky.mes.em.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import cn.b.sky.mes.em.dao.ProductionPerformanceDao;
import cn.b.sky.mes.em.model.ProductionPerformance;
import cn.b.sky.mes.em.model.condition.ProductionPerformanceCondition;
import cn.b.sky.mes.em.service.ProductionPerformanceService;

@Service("productionPerformanceService")
public class ProductionPerformanceServiceImpl implements ProductionPerformanceService {

  @Resource
  ProductionPerformanceDao productionPerformanceDao;

  @Override
  public List<ProductionPerformance> selectProductionPerformanceListByCondition(ProductionPerformanceCondition condition) {
    if (condition == null) {
      condition = new ProductionPerformanceCondition();
    }
    if (StringUtils.isBlank(condition.getOrderField())) {
      condition.setOrderField("EquipmentCode");
    }
    return productionPerformanceDao.selectProductionPerformanceListByCondition(condition);
  }

  @Override
  public int selectProductionPerformanceCountByCondition(ProductionPerformanceCondition condition) {
    if (condition == null) {
      condition = new ProductionPerformanceCondition();
    }
    return productionPerformanceDao.selectProductionPerformanceCountByCondition(condition);
  }

}
